package com.alibaba.algo.dao.user;

import com.alibaba.algo.cooperation.feign.vo.req.SelectPositionListByUserReqVO;
import com.alibaba.algo.cooperation.feign.vo.req.SelectPositionUserReqVO;
import com.alibaba.algo.cooperation.usercomponent.vo.req.user.SelectPositionListRequestVO;
import com.alibaba.algo.core.base.BaseMapper;
import com.alibaba.algo.dtos.user.PositionUserDTO;
import com.alibaba.algo.dtos.user.SysPositionDTO;
import com.alibaba.algo.entity.user.SysPosition;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 类SysPositionMapper.java的实现描述：岗位Mapper
 *
 * @author nieganggang 2021-03-12 16:08:17
 */
public interface SysPositionMapper extends BaseMapper<SysPosition> {

    /**
     * 更新当前组织的主岗位为非主岗
     *
     * @param orgId 组织id
     * @return 更新结果
     */
    Integer updateMainPositionByOrgId(@Param("orgId") Long orgId);

    SysPosition getOne(@Param("obj") SysPosition obj,@Param("sort") String sort);

    SysPosition getOneWithIsDeleted(@Param("obj") SysPosition obj,@Param("sort") String sort);

    Long selectOrgByPositionId(@Param("positionId") Long positionId);

    List<String> listDistinctPositionNames();

    /**
     * 根据岗位编码逻辑删除岗位信息
     * @param posCode
     * @return
     */
    Integer updatePositionStatusByPosCode(@Param("posCode") String posCode);

    /**
     * 根据岗位编码更新岗位信息
     * @param obj
     * @return
     */
    Integer updateByPosCode(@Param("obj") SysPosition obj);

    List<PositionUserDTO> listUserByAppAndPosition(@Param("param") SelectPositionUserReqVO vo);

    List<SysPositionDTO> listPositionOrgByPara(@Param("obj") SysPosition obj, @Param("sort") String sort);

    /**
     * 查询岗位用户信息
     * @param vo
     * @return
     */
    List<PositionUserDTO> selectPositionListByUser(@Param("param") SelectPositionListByUserReqVO vo);

    /**
     * 获取岗位下的用户列表
     *
     * @param vo 岗位标识
     * @return 用户列表
     */
    List<PositionUserDTO> selectUserListByPosition(@Param("param") SelectPositionUserReqVO vo);

    /**
     * 获取岗位下的用户列表(支持全量查询)
     *
     * @param vo 岗位标识
     * @return 用户列表
     */
    List<PositionUserDTO> selectUserListWithIsDeletedByPosition(@Param("param") SelectPositionUserReqVO vo);

    Integer deleteByPosCode(@Param("posCode") String posCode);

    List<SysPositionDTO> selectListByOrgIdAndEmployeeId(@Param("orgId") Long orgId,@Param("employeeId") Long employeeId);

    List<SysPosition> qryPositionListByOrgIdAndName(@Param("obj") SelectPositionListRequestVO vo);
}
